package src.com.itheima.mapper;

import com.itheima.domain.Classes;
import org.apache.ibatis.annotations.One;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.mapping.FetchType;

import java.util.List;

public interface ClassesMapper {

    @Select("SELECT * FROM classes")
    @Results({
            @Result(column ="cid",property = "cid",id = true),
            @Result(column ="cname",property = "cname"),
            @Result(
                    property = "students",
                    javaType = List.class,
                    column = "cid",
                    one = @One(select = "com.itheima.mapper.StudentMapper.findByCid",fetchType = FetchType.LAZY)
            )
    })

    List<Classes> findAll();


}
